#!D:\Perl\bin\perl.exe
##
## generate a Unix Cypted password
## muquit, Jun-12-1999

use strict;

my @saltchars=('a'..'z','A'..'Z','0'..'9',',','/');
my $salt='';
my $crypted_pass='';
my $word='';

my $me=$0;
$me =~ s/.*\///g;

my $usage="
    usage: $me <word> [salt]

Example:
    $me test
        [salt (first 2 characters of the crypted password) will be created]
    output: test -> s2LdDZaqAHh9c

    $me test xy
        [you supplied salt xy will be used]
    output: test -> xyVSuHLjceD92
        
";

if (($#ARGV+1) < 1)
{
    print "$usage";

    exit;
}

$word=$ARGV[0];
$salt=$ARGV[1];


if (! $salt)
{
    # random seed
    srand(time() ^ ($$ + ($$ << 15)));
    $salt=$saltchars[int(rand(64))];
    $salt .= $saltchars[int(rand(64))];
}

$crypted_pass=crypt($word,$salt);
print "$word -> $crypted_pass\n";
        



